<?php
/**
 * @author Rizky Tahara Shita
 * @website http://tahara.web.id
 * @email rizky.tahara@gmail.com
 * @copyright b'IT Cyber Solution
 */

require_once(APPPATH.'controllers/admin/applications.php');
class Work_location extends Applications
{
	public function __construct()
	{
		parent::__construct();

		/**
		 * @description check the session variables
		 */
		$this->M_login->session_check();

		/**
		 * @description the URL
		 */
		$this->bz_segment['URL'] = $this->M_functions->segment_create();
		$this->bz_segment['SITE_URL'] = site_url($this->bz_segment['URL']);

		/**
		 * @description access rights
		 */
		$this->access_rights = $this->M_menu->valid_check('db_default', $this->session->userdata('session_user_id'));
		$this->access_rights = array
			(
				'ADD' => in_array('add', $this->access_rights) ? TRUE : FALSE
				, 'EDIT' => in_array('edit', $this->access_rights) ? TRUE : FALSE
				, 'DELETE' => in_array('delete', $this->access_rights) ? TRUE : FALSE
			);

		/**
		 * @description initialize variables for database
		 */
		$this->tbl_attr = array
			(
				'TABLE' => array
					(
						'NAME' => 'hris_organization_company'
						, 'NAME_ALIAS' => 'hris_organization_company a'
						, 'PRIMARY' => array
							(
								'SHOW' => FALSE
								, 'DATA' => array('id')
							)
					)
				, 'TABLE_MODAL' => array
					(
						'NAME' => 'hris_organization_company_work_location'
						, 'NAME_ALIAS' => 'hris_organization_company_work_location b'
						, 'PRIMARY' => array
							(
								'SHOW' => FALSE
								, 'DATA' => array('id')
							)
					)
				, 'VIEW_DETAIL' => array
					(
						'HEADING' => array
							(
								$this->lang->line('hris_code')
								, $this->lang->line('hris_name')
								, $this->lang->line('hris_area_country')
								, $this->lang->line('hris_area_province')
								, $this->lang->line('hris_area_city')
								, $this->lang->line('hris_phone')
								, $this->lang->line('hris_fax')
								, $this->lang->line('hris_email')
								, $this->lang->line('hris_company_concept')
								, $this->access_rights['DELETE'] ? '&nbsp;' : NULL
							)
						, 'FIELDS' => 'id, code, name'
								. ', (select name from bz_hris_master_area c where c.id = b.country__id) as country_name'
								. ', (select name from bz_hris_master_area c where c.id = b.province__id) as province_name'
								. ', (select name from bz_hris_master_area c where c.id = b.city__id) as city_name'
								. ', phone, fax, email'
								. ', `fn_hris_master_data_get_name`("18", company_concept__id, "'.$this->session->userdata('session_user_language_id').'") as company_concept_name'
						, 'FIELDS_EDIT' => 'name'
						, 'FIELDS_ORDER' => 'name'
					)
				, 'FORM' => array
					(
						'FIELDS' => 'id, code'
						, 'FIELDS_ORDER' => ''
						, 'COLUMN' => 4
					)
				, 'FORM_MODAL' => array
					(
						'HEADING' => $this->lang->line('hris_modal')
						, 'FIELDS' => 'id, company__id, parent_id, code, name, address'
								. ', country__id'
								. ', concat("ajax_call::", "'.$this->bz_segment['SITE_URL'].'", "::ajx_live_area_::combo_put::", country__id, "/46/77/::", province__id) as province_id'
								. ', concat("ajax_call::", "'.$this->bz_segment['SITE_URL'].'", "::ajx_live_area_::combo_put::", province__id, "/47/78/::", city__id) as city_id'
								. ', phone, fax, email, company_concept__id, building_status'
						, 'FIELDS_ORDER' => ''
						, 'COLUMN' => 4
						, 'COLUMN_JOIN' => 2
					)
				, 'URL' => array
					(
						'FORM' => $this->bz_segment['SITE_URL'].'/form'
						, 'VIEW' => $this->bz_segment['SITE_URL'].'/view'
					)
			);

		$this->tbl_viewdetail_attr = array
			(
				'NAME' => $this->tbl_attr['TABLE_MODAL']['NAME_ALIAS']
				, 'PRIMARY' => $this->tbl_attr['TABLE_MODAL']['PRIMARY']
				, 'HEADING' => $this->tbl_attr['VIEW_DETAIL']['HEADING']
				, 'FIELDS' => array
					(
						'NAME' => $this->tbl_attr['VIEW_DETAIL']['FIELDS']
						, 'CAPTION' => $this->tbl_attr['VIEW_DETAIL']['FIELDS_EDIT']
						, 'ORDER' => $this->tbl_attr['VIEW_DETAIL']['FIELDS_ORDER']
						, 'PARENT_NAME' => 'parent_id'
						, 'ROOT_SHOW' => FALSE
					)
				, 'JAVASCRIPT' => array
					(
						'VIEWLIST_GENERATE' => array
							(
								'JS_FUNCTION_NAME' => 'js_modaldialog_data_put'
								, 'JS_FUNCTION_PARAMETERS' => '"'.$this->bz_segment['SITE_URL'].'/ajx_live_form_detail/" + $("#txt0").val(), "frm_modal", "txt0", "txt71", "js_modal_functions", "'.$this->bz_segment['SITE_URL'].'", "ajx_modal_data_", "put"'
							)
					)
			);

		/**
		 * @description template lite variables
		 */
		$this->bz_tlite_var['CACHE_PATH'] = $this->bz_tlite_var['SESSION']['USER_ID'].'|'.str_replace('/', '|', $this->bz_segment['URL']);
		$this->bz_tlite_var['CACHE'] = array
			(
				'PUBLIC' => $this->bz_tlite_var['SESSION']['USER_ID']
				, 'PRIVATE' => array
					(
						'GLOBAL' => $this->bz_tlite_var['CACHE_PATH']
						, 'FORM' => $this->bz_tlite_var['CACHE_PATH'].'|form'
					)
			);
	}


	/**
	 * @function index()
	 * @description main controller
	 */
	public function index()
	{
		/**
		 * @description choose which controller to show
		 */
		redirect($this->tbl_attr['URL']['FORM']);
	}


	/**
	 * @function form()
	 * @description form for data entry
	 */
	public function form()
	{
		if ($this->web_data['BISKITZ']['HEADER']['BROWSER_SUPPORTED'] == '')
		{
			/**
			 * @description if the user has ADD or EDIT access, show the form!
			 */
			if ($this->access_rights['ADD'] OR $this->access_rights['EDIT'])
			{
				/**
				 * @description if there isn't any css/ajax cache, build it! else show cache!
				 */
				if ( ! $this->bz_tlite->is_cached($this->bz_tlite_var['NAMES']['CSS'], $this->bz_tlite_var['CACHE']['PRIVATE']['FORM']))
				{
					/**
					 * @section begin page init
					 */
						/**
						 * @description show the menu
						 */
						$menu = $this->M_menu->shows();
						$this->web_data['JAVASCRIPT_MENU'] = $menu['JAVASCRIPT_MENU'];
						$this->web_data['PAGE']['MENU'] = $menu['PAGE']['MENU'];

						/**
						 * @description init the css and the ajax needed
						 */
						$css_files = array
							(
								array('layout' => 'screen')
								, array('tipsy/tipsy' => 'screen')
								, array('validate/validate' => 'screen')
								, array('form_icon_bar' => 'screen')
								, array('nanoscroller/nanoscroller' => ($menu['PAGE']['MENU']['FAVORITE']['LIST'] != 'Error') ? 'screen' : NULL)
								, array('shortcut_bar' => ($menu['PAGE']['MENU']['FAVORITE']['LIST'] != 'Error') ? 'screen' : NULL)
								, array('jqModal/jqModal' => 'screen')
								, array('ddm/multi-ddm' => 'screen')
							);
						$js_files = array
							(
								'js/plugins/ddm' => array('jquery.multi-ddm.pack')
								, 'js/plugins/nanoscroller' => ($menu['PAGE']['MENU']['FAVORITE']['LIST'] != 'Error') ? array('jquery.nanoscroller.min', 'overthrow.min') : NULL
								, 'js/plugins/validate' => array('jquery.validate.pack', 'additional-methods', 'jquery.metadata')
								, 'js/plugins/tipsy' => array('jquery.tipsy.pack')
								, 'js/plugins/jqModal' => array('jqModal.pack')
								, $this->web_data['BISKITZ']['SETTINGS']['BISKITZ_JS_FUNCTIONS_PATH'] => array('common', 'form', 'error', 'modaldialog')
								, 'themes/'.$this->web_data['BISKITZ']['SETTINGS']['BISKITZ_THEME_ADMIN'].'/'.$this->web_data['BISKITZ']['SETTINGS']['BISKITZ_JS_PATH'] => array('common')
							);
					/**
					 * @section end page init
					 */


					/**
					 * @section begin form initialize
					 */
						/**
						 * @description load the models
						 */
						$this->load->model('admin/hris/HRIS_M_live_data');


						$shortcut_f8_action = '$(\'#btn_add_detail\').click();';
						/**
						 * @description initialize the form elements
						 */
						$form_content = array
							(
								'<b>'.$this->lang->line('hris_company_name').'</b>'
								, form_dropdown
									(
										'txtinput[0]'
										, $this->HRIS_M_live_data->combo_fill('db_default', 'company_profile', '', 'RECURSIVE', array(), FALSE)
										, ''
										, 'id="txt0" class="{validate: {required: true}}"'
											. ' shortcut_f8="'.$shortcut_f8_action.'"'
									)


									. (
											$this->access_rights['ADD']
											? form_button
												(
													array('id' => 'btn_add_detail', 'class' => 'input_default hidden')
													, $this->lang->line('button_add_detail')
												)
											: NULL
										)
							);

						/**
						 * @description create the form and elements
						 */
						$this->table->clear();
						$table_template = array('table_open' => '<table class = "plain">');
						$this->table->set_template($table_template);

						$form_content = $this->table->make_columns($form_content, $this->tbl_attr['FORM']['COLUMN']);
						$form_content = $this->table->generate($form_content);
					/**
					 * @section end form initialize
					 */



					/**
					 * @section begin generate template variables
					 */
						/**
						 * @description css and ajax
						 */
						$this->web_data['PAGE']['CSS_FILES'] = $this->M_template->css_generate($css_files, $this->web_data['BISKITZ']['SETTINGS']['BISKITZ_THEME_ADMIN']);
						$this->web_data['PAGE']['JAVASCRIPT_FILES'] = $this->M_template->js_generate($js_files);

						/**
						 * @description initialize the additional javascript
						 */
						$this->web_data['JAVASCRIPT'] .= '
							<script>
								var js_modal_functions =
								"
									$(\"#btn_modal_save\").click
										(function()
										{
											js_form_action_validate
											(
												\"'.$this->bz_segment['SITE_URL'].'\", \"ajx_modal_\", \"insert\", \"\"
												, \"#frm_modal\", \"#process_modaldialog\", \"#error_message_modaldialog\"
												, \"validate\"
											);

											$(\"#txt72\").focus().select();
										});


									$(\"#txt76\").change(function()
										{
											$(\"#txt77, #txt78\").empty()
												.append( $(\"<option></option>\").val(\"\").html(\"'.$this->lang->line('hris_choose').'\") );

											if ($(this).val() != \"\")
											{
												js_form_action
												(
													\"'.$this->bz_segment['SITE_URL'].'\", \"ajx_live_area_\", \"combo_put\", $(this).val() + \"/46/77\"
													, \"#frm_header\", \"#process\", \"#error_message\"
												);
											}
										}
									);

									$(\"#txt77\").change(function()
										{
											$(\"#txt78\").empty()
												.append( $(\"<option></option>\").val(\"\").html(\"'.$this->lang->line('hris_choose').'\") );

											if ($(this).val() != \"\")
											{
												js_form_action
												(
													\"'.$this->bz_segment['SITE_URL'].'\", \"ajx_live_area_\", \"combo_put\", $(this).val() + \"/47/78\"
													, \"#frm_header\", \"#process\", \"#error_message\"
												);
											}
										}
									);
								";



								$(function()
								{
									$("#txt0").change
										(function()
										{
											if ($("#txt0").val() != "")
											{
												js_form_action
												(
													"'.$this->bz_segment['SITE_URL'].'", "ajx_data_", "put", $("#txt0").val()
													, "#frm_header", "#process", "#error_message"
												);
											}
											else
											{
												$("#content_replace").replaceWith("<div id=\"content_replace\"></div>");
											}
										});


									$("#btn_add_detail").click
										(function()
										{
											if ($("#txt0").val() != "")
											{
												js_modaldialog_show
												(
													"'.$this->bz_segment['SITE_URL'].'/ajx_live_form_detail/" + $("#txt0").val()
													, "frm_modal"
													, "txt0", "txt71"
													, js_modal_functions
												);
											}
											else
											{
												alert("'.$this->lang->line('hris_msg_select_value').'");
											}
										});

									$("#txt0").focus().select();
						';

						if ($menu['PAGE']['MENU']['FAVORITE']['LIST'] != 'Error')
						{
							$this->web_data['JAVASCRIPT'] .= '$(".nano").nanoScroller({preventPageScrolling: true});';
						}

						$this->web_data['JAVASCRIPT'] .= '
								});
							</script>
						';

						/**
						 * @description menu descriptions
						 */
						$this->web_data['PAGE']['DETAIL'] = $this->M_menu->detail();

						/**
						 * @description icon bar
						 */
						$this->load->model('admin/M_command_bar');
						$this->web_data['PAGE']['ICON_BAR'] = $this->M_command_bar->form('TRUE', FALSE, FALSE, TRUE, FALSE, FALSE);

						/**
						 * @description form dialogs
						 */
						$this->web_data['PAGE']['FORM'] = array
							(
								'OPEN' => form_open('', array('id' => 'frm_header', 'onSubmit' => 'return false'), '')
								, 'CONTENT' => $form_content
							);

						/**
						 * @description notes
						 */
						$this->web_data['PAGE']['NOTES'] = array
							(
								'USE' => 'TRUE'
								, 'MESSAGE' => array
									(
										'SHORTCUTS' => $this->lang->line('notes_shortcuts')
										, 'ADDITIONAL' => $this->lang->line('notes_additional_modaldialog')
									)
							);
					/**
					 * @section end generate template variables
					 */
				}


				/**
				 * @description log the action!
				 */
				$this->M_log->write('db_default', sprintf($this->lang->line('log_form_access'), $this->router->class, 'form'));
			}
			else
			{
				/**
				 * @description doesn't have ADD or EDIT access? redirect to desktop
				 */
				redirect('admin/desktop');
			}



		}
		else
		{
			/**
			 * @section Browser NOT Supported
			 */
				/**
				 * @description browser not supported message error
				 */
				$css_files = array(array('layout' => 'screen'));


				/**
				 * @section begin generate template variables
				 */
					/**
					 * @description css and ajax
					 */
					$this->web_data['PAGE']['CSS_FILES'] = $this->M_template->css_generate($css_files, $this->web_data['BISKITZ']['SETTINGS']['BISKITZ_THEME_ADMIN']);
				/**
				 * @section end generate template variables
				 */
		}



		/**
		 * @description output template variables
		 */
		$this->bz_tlite->assign('WEB_DATA', $this->web_data);


		/**
		 * @section begin output
		 */
		$this->bz_tlite->display($this->bz_tlite_var['NAMES']['HEADER'], $this->bz_tlite_var['CACHE']['PUBLIC']);
		$this->bz_tlite->display($this->bz_tlite_var['NAMES']['CSS'], $this->bz_tlite_var['CACHE']['PRIVATE']['FORM']);
		$this->bz_tlite->display($this->bz_tlite_var['NAMES']['MENU'], $this->bz_tlite_var['CACHE']['PUBLIC']);
		$this->bz_tlite->display($this->bz_tlite_var['NAMES']['CONTENT_DESCRIPTION'], $this->bz_tlite_var['CACHE']['PRIVATE']['GLOBAL']);
		$this->bz_tlite->display($this->bz_tlite_var['NAMES']['CONTENT_FORM_ICON_BAR'], $this->bz_tlite_var['CACHE']['PRIVATE']['FORM']);
		$this->bz_tlite->display($this->bz_tlite_var['NAMES']['CONTENT_FORM'], $this->bz_tlite_var['CACHE']['PRIVATE']['FORM']);
		$this->bz_tlite->display($this->bz_tlite_var['NAMES']['CONTENT_SHORTCUT_BAR'], $this->bz_tlite_var['CACHE']['PUBLIC']);
		$this->bz_tlite->display($this->bz_tlite_var['NAMES']['FOOTER'], $this->bz_tlite_var['CACHE']['PUBLIC']);
		$this->bz_tlite->display($this->bz_tlite_var['NAMES']['JAVASCRIPT'], $this->bz_tlite_var['CACHE']['PRIVATE']['FORM']);

		$this->bz_tlite->cache = FALSE;
		$this->bz_tlite->display($this->bz_tlite_var['NAMES']['JAVASCRIPT_EXTEND']);

		$this->bz_tlite->cache = TRUE;
		$this->bz_tlite->display($this->bz_tlite_var['NAMES']['FOOTER_END'], $this->bz_tlite_var['CACHE']['PUBLIC']);
		/**
		 * @section end output
		 */
	}



/**
 * @section AJAX Action Section
 */

	/**
	 * @function ajx_data_put()
	 * @description get the data from database and put them to the form via ajax!
	 */
	public function ajx_data_put($prm_key = '')
	{
		if ($this->input->is_ajax_request() && $this->access_rights['EDIT'] && trim($prm_key) != '')
		{
			/**
			 * @description load the models
			 */
			$this->load->model('admin/M_live_data');
			/**
			 * @description load the helper
			 */
			$this->load->helper('viewlist');


			$return_value = $this->M_live_data->put
				(
					'db_default'
					, $this->tbl_attr['TABLE']['NAME']
					, array('id' => $prm_key)
					, $this->tbl_attr['FORM']['FIELDS']
					, 0, 'log_form_edit', 'form'

					, 'js_action_data_detail'
					, array
						(
							'FUNCTION_NAME' => 'detail_generate'
							, 'FUNCTION_ATTR' => array
								(
									'db_default'
									, $this->tbl_viewdetail_attr
									, array('company__id' => $prm_key)
									, $this->tbl_viewdetail_attr['JAVASCRIPT']['VIEWLIST_GENERATE']
									, 'RECURSIVE'
								)
						)
				);


			$return_value = json_encode($return_value);
			echo $return_value;
		}
	}



/**
 * @section AJAX MODAL Action Section
 */

	/**
	 * @function ajx_modal_data_put()
	 * @description get the data from database and put them to the form via ajax!
	 */
	public function ajx_modal_data_put($prm_id = '')
	{
		if ($this->input->is_ajax_request() && $this->access_rights['EDIT'] && trim($prm_id) != '')
		{
			/**
			 * @description load the models
			 */
			$this->load->model('admin/M_live_data');


			$return_value = $this->M_live_data->put
				(
					'db_default'
					, $this->tbl_attr['TABLE_MODAL']['NAME_ALIAS']
					, array('id' => $prm_id)
					, $this->tbl_attr['FORM_MODAL']['FIELDS']
					, 70
					, 'log_form_edit'
					, 'modal'
				);


			$return_value = json_encode($return_value);
			echo $return_value;
		}
	}


	/**
	 * @function ajx_modal_insert()
	 * @description insert the detail data
	 */
	public function ajx_modal_insert()
	{
		if ($this->input->is_ajax_request() && ($this->access_rights['ADD'] OR $this->access_rights['EDIT']))
		{
			if ($this->input->post('txtinput[70]') != $this->input->post('txtinput[72]'))
			{
				/**
				 * @description load the models
				 */
				$this->load->model('admin/M_live_data');
				/**
				 * @description load the helper
				 */
				$this->load->helper('viewlist');


				/**
				 * @description process the header
				 */
				$header = array('ID' => $this->input->post('txtinput[71]'));



				/**
				 * @description process the detail
				 */
				$detail = array
					(
						'KEY' => array('id' => $this->input->post('txtinput[70]'))
						, 'DATA' => array
							(
								'id' => trim($this->input->post('txtinput[70]')) != '' ? $this->input->post('txtinput[70]') : NULL
								, 'company__id' => $header['ID']
								, 'parent_id' => $this->input->post('txtinput[72]')
								, 'code' => $this->input->post('txtinput[73]')
								, 'name' => $this->input->post('txtinput[74]')
								, 'address' => $this->input->post('txtinput[75]')
								, 'country__id' => $this->input->post('txtinput[76]')
								, 'province__id' => $this->input->post('txtinput[77]')
								, 'city__id' => $this->input->post('txtinput[78]')
								, 'phone' => $this->input->post('txtinput[79]')
								, 'fax' => $this->input->post('txtinput[80]')
								, 'email' => $this->input->post('txtinput[81]')
								, 'company_concept__id' => $this->input->post('txtinput[82]')
								, 'building_status' => $this->input->post('txtinput[83]')
							)
					);

				$detail_return = $this->M_live_data->insert
					(
						'db_default'
						, $this->tbl_attr['TABLE_MODAL']['NAME']
						, $detail['KEY']
						, $detail['DATA']
						, 'modal'
						, TRUE, ''
						, FALSE
					);
				$modaldialog_status = 'modaldialog_close_auto';



				/**
				 * @description generate the viewlist live!
				 */
				$return_value = array
					(
						'js_action_modal_insert'
						, $detail_return[1], array($header['ID'])

						/**
						 * @description the header id in the MODAL form, use it to sync with the main form
						 */
						, 71

						/**
						 * @description put the header data to main form after success inserting detail data
						 */
						, array('#txt0', $header['ID'])

						/**
						 * @description generate the detail view list, LIVE!
						 */
						, array
							(
								'content_replace'
								, detail_generate
									(
										'db_default'
										, $this->tbl_viewdetail_attr
										, array('company__id' => $header['ID'])
										, $this->tbl_viewdetail_attr['JAVASCRIPT']['VIEWLIST_GENERATE']
										, 'RECURSIVE'
									)
							)

						/**
						 * @description trigger the dialog to be automatically closed
						 */
						, array($modaldialog_status)
					);
			}
			else
			{
				$return_value = array
					(
						'js_action_message_not_clear'
						, array($this->lang->line('hris_msg_parent_same_level_error'), 'error')
					);
			}


			$return_value = json_encode($return_value);
			echo $return_value;
		}
	}


	/**
	 * @function ajx_modal_delete()
	 * @description delete the detail data
	 */
	public function ajx_modal_delete($prm_id = '', $prm_return_type = 'boolean')
	{
		if ($this->input->is_ajax_request() && $this->access_rights['DELETE'] && trim($prm_id) != '')
		{
			/**
			 * @description load the models
			 */
			$this->load->model('admin/M_live_data');


			$return_value = $this->M_live_data->delete
				(
					'db_default'
					, $this->tbl_attr['TABLE_MODAL']['NAME']
					, $prm_id
					, array()
					, array('id')
					, 'modal'
					, FALSE
					, $prm_return_type
				);

			switch ($return_value)
			{
				case 'DELETE_SUCCESS':
					/**
					 * @description load the helper
					 */
					$this->load->helper('viewlist');


					$return_value = array
						(
							'js_action_content_replace'
							, array
								(
									'content_replace'
									, detail_generate
										(
											'db_default'
											, $this->tbl_viewdetail_attr
											, array('company__id' => $this->input->post('txtinput[0]'))
											, $this->tbl_viewdetail_attr['JAVASCRIPT']['VIEWLIST_GENERATE']
											, 'RECURSIVE'
										)
								)
						);
					break;
			}


			$return_value = json_encode($return_value);
			echo $return_value;
		}
	}



/**
 * @section AJAX Live Section
 */

	/**
	 * @function ajx_live_area_combo_put()
	 * @description get the data and put them in combobox
	 */
	public function ajx_live_area_combo_put($prm_parent_id = '0', $prm_area_type_id = '', $prm_object_start = '0', $prm_selected_value = '')
	{
		if ($this->input->is_ajax_request() && trim($prm_area_type_id) != '')
		{
			/**
			 * @description load the models
			 */
			$this->load->model('admin/hris/HRIS_M_live_data');


			$return_value = $this->HRIS_M_live_data->combo_fill('db_default', 'hris_master_area', $prm_object_start, 'NORMAL', array('parent_id' => $prm_parent_id, 'area_type__id' => $prm_area_type_id), TRUE, $prm_selected_value);


			$return_value = json_encode($return_value);
			echo $return_value;
		}
	}


	/**
	 * @function ajx_live_form_detail
	 * @description generate the detail form via ajax
	 */
	public function ajx_live_form_detail($prm_key = '')
	{
		if ($this->input->is_ajax_request() && ($this->access_rights['ADD'] OR $this->access_rights['EDIT']))
		{
			/**
			 * @description load the models
			 */
			$this->load->model(array('admin/M_layout', 'admin/hris/HRIS_M_live_data'));


			/**
			 * @section begin form MODAL initalize
			 */
				/**
				 * @description create the MODAL form and elements
				 */
				$form_modal_content_join[] = array
					(
						'<b>'.$this->lang->line('hris_parent').'</b>'
						, array
							(
								'data' => form_input
									(
										array
										(
											'type' => 'hidden'
											, 'name' => 'txtinput[70]', 'id' => 'txt70'
											, 'size' => '18', 'maxlength' => '18'
											, 'readOnly' => 'readOnly', 'class' => 'read_only'
										)
									)
									. form_input
										(
											array
											(
												'type' => 'hidden'
												, 'name' => 'txtinput[71]', 'id' => 'txt71'
												, 'size' => '10', 'maxlength' => '10'
												, 'readOnly' => 'readOnly', 'class' => 'read_only'
											)
											, $prm_key
										)
									. form_dropdown
										(
											'txtinput[72]'
											, $this->HRIS_M_live_data->combo_fill('db_default', 'company_work_location', '', 'RECURSIVE', array('company__id' => $prm_key))
											, ''
											, 'id="txt72" class="{validate: {required: true}}"'
										)
								, 'colspan' => 3
							)
					);

				$form_modal_content[] = array
					(
						'<b>'.$this->lang->line('hris_code').'</b><br /><small>'.$this->lang->line('fields_required').'</small>'
						, form_input
							(
								array
								(
									'name' => 'txtinput[73]', 'id' => 'txt73'
									, 'size' => '7', 'maxlength' => '7'
									, 'class' => '{validate: {required: true}}'
								)
							)

						, '<b>'.$this->lang->line('hris_name').'</b><br /><small>'.$this->lang->line('fields_required').'</small>'
						, form_input
							(
								array
								(
									'name' => 'txtinput[74]', 'id' => 'txt74'
									, 'size' => '20', 'maxlength' => '40'
									, 'class' => '{validate: {required: true}}'
								)
							)
					);

				$form_modal_content_join[] = array
					(
						array('data' => '<b>'.$this->lang->line('hris_address').'</b>', 'valign' => 'top')
						, array
							(
								'data' => form_textarea
									(
										array
										(
											'name' => 'txtinput[75]', 'id' => 'txt75'
											, 'cols' => '80', 'rows' => '2'
										)
									)
								, 'colspan' => 3
							)

						, '<b>'.$this->lang->line('hris_area_country').'</b>'
						, array
							(
								'data' => form_dropdown
									(
										'txtinput[76]'
										, $this->HRIS_M_live_data->combo_fill('db_default', 'hris_master_area', '', 'NORMAL', array('parent_id' => 0))
										, ''
										, 'id="txt76" class="{validate: {required: true}}"'
									)
								, 'colspan' => 3
							)

						, '<b>'.$this->lang->line('hris_area_province').'</b>'
						, array
							(
								'data' => form_dropdown
									(
										'txtinput[77]'
										, array('' => $this->lang->line('hris_choose'))
										, ''
										, 'id="txt77" class="{validate: {required: true}}"'
									)
								, 'colspan' => 3
							)

						, '<b>'.$this->lang->line('hris_area_city').'</b>'
						, array
							(
								'data' => form_dropdown
									(
										'txtinput[78]'
										, array('' => $this->lang->line('hris_choose'))
										, ''
										, 'id="txt78" class="{validate: {required: true}}"'
									)
								, 'colspan' => 3
							)
					);

				$form_modal_content[] = array
					(
						'<b>'.$this->lang->line('hris_phone').'</b>'
						, form_input
							(
								array
								(
									'name' => 'txtinput[79]', 'id' => 'txt79'
									, 'size' => '20', 'maxlength' => '20'
									, 'shortcut_f2' => $this->tbl_attr['URL']['VIEW']
								)
							)

						, '<b>'.$this->lang->line('hris_fax').'</b>'
						, form_input
							(
								array
								(
									'name' => 'txtinput[80]', 'id' => 'txt80'
									, 'size' => '20', 'maxlength' => '20'
									, 'shortcut_f2' => $this->tbl_attr['URL']['VIEW']
								)
							)
					);

				$form_modal_content_join[] = array
					(
						'<b>'.$this->lang->line('hris_email').'</b>'
						, array
							(
								'data' => form_input
									(
										array
										(
											'name' => 'txtinput[81]', 'id' => 'txt81'
											, 'size' => '40', 'maxlength' => '60'
											, 'class' => '{validate: {email: true}}'
											, 'shortcut_f2' => $this->tbl_attr['URL']['VIEW']
										)
									)
								, 'colspan' => 3
							)
					);

				$form_modal_content[] = array
					(
						'<b>'.$this->lang->line('hris_company_concept').'</b>'
						, form_dropdown
							(
								'txtinput[82]'
								, $this->HRIS_M_live_data->combo_fill('db_default', 18)
								, ''
								, 'id="txt82" class="{validate: {required: true}}"'
							)

						, '<b>'.$this->lang->line('hris_work_location_building_status').'</b>'
						, form_dropdown
							(
								'txtinput[83]'
								, array
									(
										'Own' => $this->lang->line('hris_work_location_building_status_own')
										, 'Contract' => $this->lang->line('hris_work_location_building_status_contract')
									)
								, ''
								, 'id="txt83"'
							)


						, '&nbsp;'
						, form_submit
							(
								array('id' => 'btn_modal_save')
								, $this->lang->line('button_save')
							)
					);
				/**
				 * @description create the form MODAL and elements
				 */
				$this->table->clear();
				$form_modal[] = $this->table->make_columns($form_modal_content_join[0], $this->tbl_attr['FORM_MODAL']['COLUMN_JOIN']);
				$form_modal[] = $this->table->make_columns($form_modal_content[0], $this->tbl_attr['FORM_MODAL']['COLUMN']);
				$form_modal[] = $this->table->make_columns($form_modal_content_join[1], $this->tbl_attr['FORM_MODAL']['COLUMN_JOIN']);
				$form_modal[] = $this->table->make_columns($form_modal_content[1], $this->tbl_attr['FORM_MODAL']['COLUMN']);
				$form_modal[] = $this->table->make_columns($form_modal_content_join[2], $this->tbl_attr['FORM_MODAL']['COLUMN_JOIN']);
				$form_modal[] = $this->table->make_columns($form_modal_content[2], $this->tbl_attr['FORM_MODAL']['COLUMN']);


				$form_merge = array();
				foreach ($form_modal as $form)
				{
					$form_merge = array_merge($form_merge, $form);
				}
				$form_modal_content = $this->table->generate($form_merge);
			/**
			 * @section end form MODAL initalize
			 */


			/**
			 * @section begin generate template variables
			 */
			$return_value = array
				(
					/**
					 * @description form modal dialogs
					 */
					'FORM_MODAL' => array
						(
							'OPEN' => form_open('', array('id' => 'frm_modal', 'onSubmit' => 'return false'), '')
							, 'TITLE' => $this->tbl_attr['FORM_MODAL']['HEADING']
							, 'CONTENT' => $form_modal_content
						)

					/**
					 * @description notes modaldialog
					 */
					, 'NOTES_MODAL' => array
						(
							'USE' => 'TRUE'
							, 'MESSAGE' => array
								(
									'SHORTCUTS' => $this->lang->line('notes_modaldialog_shortcuts')
									, 'ADDITIONAL' => ''
								)
						)
				);
			/**
			 * @section end generate template variables
			 */


			$return_value = $this->M_layout->modaldialog_generate($return_value);
			echo $return_value;
		}
	}



}

/** End of file work_location.php */
/** Location: ./biskitz_mpc/biskitz/controllers/admin/hris/configuration/organization/company/work_location.php */
